package com.myres.servlet;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

public class Client {
	public static void main(String[] agrs){
	try{
		System.out.println("connecting....");
		Socket socket=new Socket("127.0.0.1",8989);
		OutputStream os=socket.getOutputStream();
		PrintStream ps=new PrintStream(os);
		ps.print("12345566");
		while(true){
			try{
				Thread.sleep(500);
			}catch(Exception e){
				e.printStackTrace();
			}
			InputStream is=socket.getInputStream();
			byte[] buf=new byte[128];
			int len;
			StringBuffer sb=new StringBuffer();
			while((len=is.read(buf, 0, 128))!=-1){
				sb.append(new String(buf,0,len));
			}
			String message=sb.toString();
			System.out.println(message);
		}
		}catch(IOException e){
			e.printStackTrace();
		}
	}
}
